package edu.sjsu.cs.files;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class CopyFile
{
   public static void main(String[] args) throws FileNotFoundException
   {
      if(args.length != 2)
      {
         System.out.println("Usage: CopyFile source destination");
      }
      
      String sourceFile = args[0];
      String destinationFile = args[1];
      
      //open sourceFile for reading
      FileReader fRead = new FileReader(sourceFile);
      Scanner fScanner = new Scanner(fRead);
      
      //open destinationFile for writing
      PrintWriter outFile = new PrintWriter(destinationFile);
      
      //copy the contents
      while(fScanner.hasNextLine())
      {
         outFile.println(fScanner.nextLine());
      }
      
      
      //close files
      fScanner.close();
      outFile.close();
      
      
      
   }

}
